<template>
  <div>
    <el-dialog title="查看会员卡明细" class="noselect"
               v-dialogdrag=" { target:'.el-dialog__header',container:'.el-dialog',border:'.el-dialog__wrapper'}"
               :close-on-click-modal="false" :visible.sync="showDialog" :before-close="handleClose">
      <div style="margin: 20px;"></div>
      <el-table
        v-loading="loading"
        :data="tableData"
        :border="true"
        style="width: 100%">
        <el-table-column
          type="index"
          width="50">
        </el-table-column>
        <el-table-column
          label="卡号">
          <template  slot-scope="scope">
            <span >{{scope.row.card_no}}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="卡类型">
          <template  slot-scope="scope">
            <span >{{scope.row.type_name}}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="办卡押金">
          <template  slot-scope="scope">
            <span >{{scope.row.deposit}}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="卡有效期">
          <template  slot-scope="scope">
            <span >{{scope.row.periodText}}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="配送状态">
          <template  slot-scope="scope">
            <span >{{scope.row.stateText}}</span>
          </template>
        </el-table-column>
      </el-table>
      <br>
      <div class="block">
        <el-row>
          <el-col :span="24" class="text-right">
            <el-pagination
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="currentPage"
              :page-sizes="pageSizes"
              :page-size="pageSize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="total">
            </el-pagination>
          </el-col>
        </el-row>
      </div>
      <div class="foot-bar-button">
        <el-button type="primary" @click="handleClose" size="medium">取消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
//注意路径
export default {
  props: ["isShow", "id"], //参数
  data() {
    return {
      modelForm: {},
      showDialog: false,
      activityId: "",
      isSave: true,
      downCategeryId: [],
      isUpdate: false,
      treeData: [],
      tableData:[],
      pageSizes:window.pageSizes,//所有可选择的条数
      pageSize:window.pageSize,//控制一页显示的条数
      total:10,//总条数
      currentPage:1,
      loading:false
    };
  },
  watch: {
    isShow: function(newValue, oldValue) {
      this.showDialog = newValue;
      if (newValue) {
        if (this.id != "") {
          this.activityId = this.id;
          this.isSave = false;
          this.isUpdate = true;
this.getData();

        }
      }
    }
  },
  created() {
    window.this = this;
  },
  methods: {
    getData(){
      // this.loading=true;
      this.$axios.get("members/deliveryRecords/showDetails?id="+this.id+"&page.pn="+this.currentPage+"&page.size="+this.pageSize).then((data)=>{
        this.loading=false
        this.treeData=data.content.treeData
        this.tableData=data.content.content;
        this.total=data.content.totalElements
      }).catch(function(err){
      })
    },
    newLabel(newList) {
      if (newList) {
        for (var i = 0; i < newList.length; i++) {
          newList[i].label = newList[i].name;
          newList[i].value = newList[i].id + "";
          newList[i].children = null;
        }
      }
    },
    goBack() {
      this.router.go(-1);
    },
    handleSizeChange(val){
      this.pageSize=val;
      this.getData();
    },
    handleCurrentChange(currentPage){
      this.currentPage=currentPage;
      this.getData();
    },
    handleClose() {
      this.$emit("close");
//      done();
    },
    isNum(item, key) {
      var r = /^\+?[1-9][0-9]*$/;
      if (!r.test(item[key])) {
        item[key] = "0.00";
      } else {
        item[key] = item[key];
      }
    },
    isDouble(item, key) {
      var isNum = /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/;
      if (!isNum.test(item[key])) {
        item[key] = "0.00";
      } else {
        item[key] = item[key];
      }
    }
  }
};
</script>
<style scoped>
</style>
